package com.amox.uitest.adapter;

import org.dom4j.Element;

import com.amox.uitest.kit.LogKit;
import com.amox.uitest.kit.StrKit;
import com.amox.uitest.tcase.BaseTestCase;

import ognl.Ognl;

public class ExecAdapter extends BaseAdapter<Boolean> {
	
	public ExecAdapter(BaseTestCase uitest) {
		super(uitest);
	}

	@Override
	public Boolean adapter(Element element) throws Exception {
		String value = StrKit.me().toSingleLine(element.getStringValue());
		try {
			value = (String)Ognl.getValue(value, BaseTestCase.context, BaseTestCase.context.getRoot());
		} finally {
			LogKit.printLog(value);
			Runtime.getRuntime().exec(value);
		}
		
		return true;
	}
}
